import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/src/widgets/common/expandable.dart';
import 'package:finance_app/src/widgets/list_item/list_header_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class ListExpandableItem extends StatelessWidget {
  final String title;
  final List<InlineSpan> titleSpans;
  final Widget content;
  final ExpandableController controller;

  const ListExpandableItem(
      {Key key, this.title, this.titleSpans, this.content, this.controller})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ExpandableNotifier(
      controller: controller,
      child: ExpandablePanel(
        header: ListHeaderItem(
          title: title,
          titleSpans: titleSpans,
          rightIcon: ValueListenableBuilder(
            valueListenable: controller,
            builder: (BuildContext context, bool value, Widget child) {
              return RotatedBox(
                quarterTurns: value ? 0 : 2,
                child: SvgPicture.asset(
                  A.assetsImagesStyleUp,
                  width: getDp(14),
                  height: getDp(10),
                  fit: BoxFit.contain,
                ),
              );
            },
          ),
        ),
        expanded: content,
        tapHeaderToExpand: true,
        hasIcon: false,
      ),
    );
  }
}
